home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / include / pangomm-1.4 / pangomm / glyphstring.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-04-20  |  8.4 KB  |  224 lines

  1. // -*- c++ -*-
  2. // Generated by gtkmmproc -- DO NOT MODIFY!
  3. #ifndef _PANGOMM_GLYPHSTRING_H
  4. #define _PANGOMM_GLYPHSTRING_H
  5.  
  6. #include <glibmm.h>
  7.  
  8. /* $Id: glyphstring.hg,v 1.1.1.1 2003/01/21 13:41:05 murrayc Exp $ */
  9.  
  10. /* glyphstring.h
  11.  *
  12.  * Copyright (C) 1998-1999 The gtkmm Development Team
  13.  *
  14.  * This library is free software; you can redistribute it and/or
  15.  * modify it under the terms of the GNU Library General Public
  16.  * License as published by the Free Software Foundation; either
  17.  * version 2 of the License, or (at your option) any later version.
  18.  *
  19.  * This library is distributed in the hope that it will be useful,
  20.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  22.  * Library General Public License for more details.
  23.  *
  24.  * You should have received a copy of the GNU Library General Public
  25.  * License along with this library; if not, write to the Free
  26.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  27.  */
  28.  
  29. #include <pangomm/font.h>
  30. #include <pangomm/glyph.h>
  31. #include <pangomm/item.h>
  32. #include <pango/pango-glyph.h>
  33. #include <pango/pango-item.h> //For PangoAnalysis.
  34.  
  35.  
  36. #ifndef DOXYGEN_SHOULD_SKIP_THIS
  37. extern "C" { typedef struct _PangoGlyphString PangoGlyphString; }
  38. #endif
  39.  
  40. namespace Pango
  41. {
  42.  
  43. /** A Pango::GlyphString is used to store strings of glyphs with geometry and visual attribute information.
  44.  * It can be measured or drawn to the screen.
  45.  */
  46. class GlyphString
  47. {
  48.   public:
  49. #ifndef DOXYGEN_SHOULD_SKIP_THIS
  50.   typedef GlyphString CppObjectType;
  51.   typedef PangoGlyphString BaseObjectType;
  52.  
  53.   static GType get_type() G_GNUC_CONST;
  54. #endif /* DOXYGEN_SHOULD_SKIP_THIS */
  55.  
  56.   GlyphString();
  57.  
  58.   explicit GlyphString(PangoGlyphString* gobject, bool make_a_copy = true);
  59.  
  60.   GlyphString(const GlyphString& other);
  61.   GlyphString& operator=(const GlyphString& other);
  62.  
  63.   ~GlyphString();
  64.  
  65.   void swap(GlyphString& other);
  66.  
  67.   ///Provides access to the underlying C instance.
  68.   PangoGlyphString*       gobj()       { return gobject_; }
  69.  
  70.   ///Provides access to the underlying C instance.
  71.   const PangoGlyphString* gobj() const { return gobject_; }
  72.  
  73.   ///Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs.
  74.   PangoGlyphString* gobj_copy() const;
  75.  
  76. protected:
  77.   PangoGlyphString* gobject_;
  78.  
  79. private:
  80.  
  81.   
  82. public:
  83.   /** Construct a string of glyphs from a string of characters.
  84.    * Given a segment of text and the corresponding Pango::Analysis structure
  85.    * returned from Pango::Context::itemize(), convert the characters into glyphs.
  86.    * You may also pass in only a sub-string of the item.
  87.    * @param text The text to process. You must pass the same string into those member functions expecting a const Glib::ustring&.
  88.    * @param analysis The analysis information return from Pango::Context::itemize().
  89.    */
  90.   GlyphString(const Glib::ustring& text, const Analysis& analysis);
  91.  
  92.   
  93.   /** Resize a glyph string to the given length.
  94.    * @param new_len The new length of the string.
  95.    */
  96.   void set_size (int new_len);
  97.  
  98.   
  99.   /** Compute the logical and ink extents of a glyph string. See the documentation
  100.    * for Pango::Font::get_glyph_extents() for details about the interpretation
  101.    * of the rectangles.
  102.    * @param font A Pango::Font.
  103.    * @param ink_rect Rectangle used to store the extents of the glyph string as drawn.
  104.    * @param logical_rect Rectangle used to store the logical extents of the glyph string.
  105.    */
  106.   void get_extents(const Glib::RefPtr<const Font>& font, Rectangle& ink_rect, Rectangle& logical_rect) const;
  107.   
  108.   /** Computes the extents of a sub-portion of a glyph string. The extents are
  109.    * relative to the start of the glyph string range (the origin of their
  110.    * coordinate system is at the start of the range, not at the start of the entire
  111.    * glyph string).
  112.    * @param start Start index.
  113.    * @param end End index (the range is the set of bytes with
  114.    *               indices such that start <= index < end).
  115.    * @param font A Pango::Font.
  116.    * @param ink_rect Rectangle used to store the extents of the glyph string range as drawn.
  117.    * @param logical_rect Rectangle used to store the logical extents of the glyph string range.
  118.    */
  119.   void get_extents(int start, int end, const Glib::RefPtr<const Font>& font, Rectangle& ink_rect, Rectangle& logical_rect) const;
  120.  
  121.   /** Computes the extents of the glyph string as drawn.
  122.    * @param font A Pango::Font.
  123.    * @return The extents of the glyph string as drawn.
  124.    */
  125.   Rectangle get_ink_extents(const Glib::RefPtr<const Font>& font) const;
  126.  
  127.   /** Computes the extents of a sub-portion of the glyph string as drawn.
  128.    * @param start The start index.
  129.    * @param end The end index.
  130.    * @param font A Panog::Font
  131.    * @return The extents of the sub-portion of the glyph string as drawn.
  132.    */
  133.   Rectangle get_ink_extents(int start, int end, const Glib::RefPtr<const Font>& font) const;
  134.  
  135.   /** Computes the logical extents of a sub-portion of the glyph string.
  136.    * @param font A Pango::Font.
  137.    * @return The logical extents of the glyph string.
  138.    */
  139.   Rectangle get_logical_extents(const Glib::RefPtr<const Font>& font) const;
  140.  
  141.   /** Computes the logical extents of a sub-portion of the glyph string.
  142.    * @param start The start index.
  143.    * @param end The end index.
  144.    * @param font A Pango::Font.
  145.    * @return The logical extents of the sub-portion of the glyph string.
  146.    */
  147.   Rectangle get_logical_extents(int start, int end, const Glib::RefPtr<const Font>& font) const;
  148.  
  149.   /** Determine the screen width corresponding to each character.
  150.    * When multiple characters compose a single cluster, the width of the entire cluster
  151.    * is divided equally among the characters.
  152.    * @param text The text corresponding to the glyphs.
  153.    * @param embedding_level The embedding level of the string.
  154.    * @return An array of integers representing the resulting character widths.
  155.    */
  156.   Glib::ArrayHandle<int> get_logical_widths(const Glib::ustring& text, int embedding_level) const;
  157.  
  158.   /** Converts from character position to x position.
  159.    * (X position is measured from the left edge of the run). Character positions are computed by dividing up each cluster into equal portions.
  160.    * @param text The text corresponding to the glyphs.
  161.    * @param analysis The analysis information return from Pango::Context::itemize().
  162.    * @param index The byte index within text.
  163.    * @param trailing Whether we should compute the result for the beginning or end of the character.
  164.    * @return The x position.
  165.    */
  166.   int index_to_x(const Glib::ustring& text, const Analysis& analysis, int index, bool trailing) const;
  167.  
  168.   /** Convert from x offset to character position.
  169.    * Character positions are computed by dividing up each cluster into equal portions.
  170.    * In scripts where positioning within a cluster is not allowed (such as Thai),
  171.    * the returned value may not be a valid cursor position; the caller must combine the
  172.    * result with the logical attributes for the text to compute the valid cursor position.
  173.    * @param text The text corresponding to the glyphs.
  174.    * @param analysis The analysis information return from Pango::Context::itemize().
  175.    * @param x_pos The x offset (in thousands of a device unit).
  176.    * @param index The location to store calculated byte index within.
  177.    * @param trailing The location to store a boolean indicating whether the user clicked on the leading or trailing edge of the character.
  178.    */
  179.   void x_to_index(const Glib::ustring& text, const Analysis& analysis, int x_pos, int& index, bool& trailing) const;
  180.  
  181.   /** Gharacter positions are computed by dividing up each cluster into equal portions.
  182.    * @return An array of Pango::GlyphInfo objects.
  183.    */
  184.   Glib::ArrayHandle<GlyphInfo> get_glyphs() const;
  185.  
  186.  
  187. };
  188.  
  189. } //namespace Pango
  190.  
  191.  
  192. namespace Pango
  193. {
  194.  
  195. /** @relates Pango::GlyphString
  196.  * @param lhs The left-hand side
  197.  * @param rhs The right-hand side
  198.  */
  199. inline void swap(GlyphString& lhs, GlyphString& rhs)
  200.   { lhs.swap(rhs); }
  201.  
  202. } // namespace Pango
  203.  
  204. namespace Glib
  205. {
  206.  
  207. /** @relates Pango::GlyphString
  208.  * @param object The C instance
  209.  * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
  210.  * @result A C++ instance that wraps this C instance.
  211.  */
  212. Pango::GlyphString wrap(PangoGlyphString* object, bool take_copy = false);
  213.  
  214. #ifndef DOXYGEN_SHOULD_SKIP_THIS
  215. template <>
  216. class Value<Pango::GlyphString> : public Glib::Value_Boxed<Pango::GlyphString>
  217. {};
  218. #endif /* DOXYGEN_SHOULD_SKIP_THIS */
  219.  
  220. } // namespace Glib
  221.  
  222. #endif /* _PANGOMM_GLYPHSTRING_H */
  223.  
  224.